import React, { useEffect } from "react";
import { connect } from 'react-redux'
import { rootState } from "@/store";
import { Dispatch, AnyAction } from "redux"
import { getPartitions } from "@/store/actions/partitions"

interface HomeProps {
    loading: Boolean;
    getPartitionDispatch: () => void;
}

const Home: React.FC<HomeProps> = (props) => {
    const { loading } = props;
    const { getPartitionDispatch } = props;
    // console.log("a");
    useEffect(() => {
        getPartitionDispatch()
    }, [])
    return (
        <div>
            {loading && <div>加载中...</div>}
        </div>
    )
}

const mapStateToProps = (state: rootState) => ({
    hotword: state.search.hotword,
    loading: state.loading,
    partitions: state.home.partitions
})
const mapDispatchToProps = (dispatch: Dispatch) => ({
    getPartitionDispatch() {
        dispatch(getPartitions())
    }
})

export default connect(mapStateToProps, mapDispatchToProps)(Home)